package com.broada.apm.util;

import groovy.lang.GroovyShell;

import java.io.File;
import java.io.IOException;

import org.codehaus.groovy.control.CompilationFailedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.broada.apm.utils.ExceptionUtils;

public class GroovyInvoker {
	private static Logger LOG = LoggerFactory.getLogger(GroovyInvoker.class);
	public static Object run(File f) {
    try {
			return new GroovyShell().evaluate(f);
		} catch (CompilationFailedException | IOException e) {
			ExceptionUtils.error(LOG, "执行脚本出错" + f, e);
			return null;
		}
	}
}
